package com.zjbti.data;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.nfc.Tag;
import android.os.Bundle;
import android.util.Log;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MyHelper myHelper=new MyHelper(getApplicationContext());
        SQLiteDatabase writableDatabase=myHelper.getWritableDatabase();
        ContentValues contentValues=new ContentValues();
        contentValues.put("name","apple");
        contentValues.put("price","18");
        long information=writableDatabase.insert("information",null,contentValues);
        writableDatabase.close();
//        myHelper.getWritableDatabase();
        String filename="data.txt";
//        String content="hello world";
//        FileOutputStream fileOutputStream=null;
//        try {
//            fileOutputStream=openFileOutput(filename,MODE_PRIVATE);
//            fileOutputStream.write(content.getBytes());
//        }catch (Exception e){
//            e.printStackTrace();
//        }finally {
//            try {
//                if(fileOutputStream!=null){
//                    fileOutputStream.close();
//                }
//            }catch (IOException e){
//                e.printStackTrace();
//            }
//        }
//        String content="";
//        FileInputStream fileInputStream=null;
//        try {
//            fileInputStream=openFileInput(filename);
//            byte[] buffer=new byte[fileInputStream.available()];
//            fileInputStream.read(buffer);
//            content=new String(buffer);
//        }catch (Exception e){
//            e.printStackTrace();
//        }finally {
//            try {
//                if(fileInputStream!=null){
//                    fileInputStream.close();
//                }
//            }catch (IOException e){
//                e.printStackTrace();
//            }
//        }

    }
}